import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
const maxDepth = 3;
const complexity = 20;

/** @type {import('eslint').Linter.Config[]} */
export default [
  { files: ["**/*.{js,mjs,cjs,ts}"] },
  {
    ignores: [
      "./server/**/*",
      "./dist/**/*",
      "**/node_modules/**",
      "**/*.{txt,md,json}",
      "examples/**/*",
    ],
  },
  { languageOptions: { globals: globals.browser } },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  {
    rules: {
      "no-unused-vars": "off",
      complexity: ["error", complexity],
      "accessor-pairs": "error",
      "arrow-body-style": ["error", "as-needed"],
      "consistent-this": ["error", "context"],
      "default-case-last": "error",
      eqeqeq: "error",
      "func-names": ["error", "never"],
      "grouped-accessor-pairs": ["error", "getBeforeSet"],
      "guard-for-in": "error",
      "init-declarations": ["error", "always"],
      "max-depth": ["error", maxDepth],
      "no-alert": "error",
      "no-array-constructor": "error",
      "no-caller": "error",
      "no-case-declarations": "error",
      "no-delete-var": "error",
      "no-div-regex": "error",
      "no-else-return": "error",
      "no-empty": ["error", { allowEmptyCatch: true }],
      "no-empty-function": ["error", { allow: ["constructors"] }],
      "no-eval": "error",
      "no-eq-null": "error",
      "no-extend-native": "error",
      "no-extra-bind": "error",
      "no-extra-boolean-cast": "error",
      "no-extra-label": "error",
      "no-global-assign": "error",
      "no-implicit-coercion": "error",
      "no-implicit-globals": "error",
      "no-var": "error",
      "no-implied-eval": "error",
      "no-inline-comments": "error",
      "no-invalid-this": "error",
      "no-iterator": "error",
      "no-label-var": "error",
      "no-labels": "error",
      "no-lone-blocks": "error",
      "no-lonely-if": "error",
      "no-loop-func": "error",
      "no-multi-assign": "error",
      "no-multi-str": "error",
      "no-new-func": "error",
      "no-new-wrappers": "error",
      "no-nonoctal-decimal-escape": "error",
      "no-octal": "error",
      "no-octal-escape": "error",
      "no-param-reassign": ["error", { props: false }],
      "no-proto": "error",
      "no-redeclare": "error",
      "no-regex-spaces": "error",
      "no-return-assign": "error",
      "no-script-url": "error",
      "@typescript-eslint/no-explicit-any": "off",
      "no-shadow-restricted-names": "error",
      "no-throw-literal": "error",
      "no-undef-init": "error",
      "no-undefined": "error",
      "no-unused-labels": "error",
      "no-useless-call": "error",
      "no-useless-catch": "error",
      "no-useless-computed-key": "error",
      "no-useless-concat": "error",
      "no-useless-constructor": "error",
      "no-useless-escape": "error",
      "no-useless-return": "error",
      "no-with": "error",
      "object-shorthand": [
        "error",
        "always",
        { avoidExplicitReturnArrows: true },
      ],
      "prefer-rest-params": "error",
      "require-yield": "error",
      "symbol-description": "error",
      "no-await-in-loop": "error",
      "no-constructor-return": "error",
      "no-duplicate-imports": "error",
      "no-promise-executor-return": "off",
      "no-self-compare": "error",
      "no-template-curly-in-string": "error",
      "no-unreachable-loop": "error",
      "no-use-before-define": "error",
      "@typescript-eslint/ban-ts-comment": "off",
      "no-unsafe-function-type": "off",
      "no-unused-expressions": "off",
      "@typescript-eslint/no-unused-expressions": "off",
      "no-constant-binary-expression": "off",
      camelcase: "off",
      "no-nested-ternary": "off",
      "array-callback-return": "off",
      "no-underscore-dangle": "off",
      "@typescript-eslint/no-this-alias": "off",
      "@typescript-eslint/no-unused-vars": "error",
    },
  },
];
